<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#szPower").click(
				function() {
					
					var dd = $("input[name=multi_sel]:checked");
					var accountNoStr= "";
					if(dd.length == 0){
						alert("请选择云商宝会员");
						return false;
					}else if(dd.length >= 16){
						alert("最多只能领取十五个云商宝会员！");
						return false;
					}else{
						
						dd.each(function(){
							accountNoStr = accountNoStr + $(this).val() + ",";
						});
						accountNoStr = accountNoStr.substring(0,accountNoStr.length-1);
						console.log(accountNoStr);
						
						$.ajax({
							url:"<%=basePath%>/operatorAuth/saveReceive.ct",
							type:"post",
							data:{"authIdList":accountNoStr},
							dataType:"json",
							success:function(result){
								var rsList = result.rsList;
								if(rsList.length > 0){
									var rsStr = "";
									for(var i = 0;i<rsList.length;i++){
										rsStr = rsStr + rsList[i] + ",";
									}
									rsStr = rsStr.substring(0,rsStr.length-1);
									alert("部分用户实名信息已被领取，成功领取"+(dd.length-rsList.length)+"个");
									
								}else{
									alert("领取成功！");
									
								}
								window.location.href="<%=basePath%>/operatorAuth/queryOperatorsAuth.ct";
								
							},error:function(){
								alert("未知错误！");
							}
						});
					}
		});
	});
	
	$(function(){
		$("#collarNum").change(function(){
			var collarNum = $(this).val();
			var checkBoxs = $(":input[name=multi_sel]");
			checkBoxs.each(function(){
				$(this).attr("checked",false);
			});
			var count = 0;
			checkBoxs.each(function(){
				
				if(count < parseInt(collarNum)){
					$(this).attr("checked","true");
				}else{
					return false;
				}
				count ++;
			}); 
		});
	})
	
	function queryForm(){
		$("#queryUserForm").attr("action","<%=basePath%>/operatorAuth/queryOperatorsAuth.ct");
		$("#queryUserForm").submit();
		
	}
	function changeNum(){
		var num = $("#collarNum").val();
		$("input[name='multi_sel']").each(function(i){ 
			$(this).removeAttr("checked"); 
		});
		if(num>0){
			$("input[name='multi_sel']").each(function(i){ 
				 if(i<num){
					 $(this).attr("checked","true");
				 }
			});
		}
	}
</script>
</head>
<body>
<s:form id="queryUserForm" action="" method="post" theme="simple">
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h3">实名领取</div></td>
        </tr>
 
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">会员手机号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.accountNo" />
               	</label>
            </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">会员姓名：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.realName" />
               	</label>
            </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">身份证号码：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.idCard" />
               	</label>
            </td>
             
        </tr>

        <tr class="tb-line">
            <td align="right" class="tb-td">实名提交时间：</td>
			<td class="tb-td" colspan="3">
				 <label class="tb-input-normal">
					<s:textfield    onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true,wdate:true,errDealMode:0});"    name="searchCondition.minDate"  />
				 </label>
				-
				 <label class="tb-input-normal">
					<s:textfield  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true,wdate:true,errDealMode:0});"   name="searchCondition.maxDate"   />
				</label>
			</td>
			<s:if test="#request.searchRsList != null && #request.searchRsList.size>0 ">
	        	<td align="right" class="tb-td">
	                <div class="tb-h4">	领取数量：</div>
	            </td>
		        <td class="tb-td">
		        	<label class="tb-select">
		        		<s:select onchange="changeNum()" id="collarNum" list="#{'5':'5','10':'10','15':'15','20':'20'}" theme="simple" headerKey="0" headerValue="请选择"></s:select>
		        	</label>
		        </td>
			</s:if>
        </tr>
		
        
        
        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="6">
                <label class="tb-input-submit">
                    <input type="button" value="查询"  onclick='queryForm()'/>
                </label>
                <label class="tb-input-submit">
                    <input type="reset" value="取消"/>
                </label>
                
	        	<label class="tb-input-submit">
                    <input id="szPower" type="button"  value="领件" />
                </label>
	        
            </td>
        </tr>
         
        <s:if test="#request.searchRsList != null && #request.searchRsList.size>0 ">
			<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="6"> 
					 	<page:pageCount max_pages="11" totalPage="${requestScope.totalPage}"
						currentPage="${requestScope.currentPage}"
						action="${rootPath}/operatorAuth/queryOperatorsAuth.ct?currentPage=" />

				</td>
			</tr>
		</s:if>
    </tbody>
</table>
</s:form>
<div class="big-tb">
    <table class="tb" style="width: 100%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="7">会员基本信息列表</th>
            </tr>
            <tr class="tb-line bg-gray">
                <th class="tb-th">选择</th>
				<th class="tb-th">会员账号</th>
				<th class="tb-th">证件类型</th>
				<th class="tb-th">真实姓名</th>
				<th class="tb-th">证件号</th>
				<th class="tb-th">有效期</th>
				<th class="tb-th">创建时间</th>
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.searchRsList" status="stat" id="sh">
				<tr class="tb-line" >
					<td align="center" class="tb-td">
						<input   name="multi_sel" value="<s:property value="#sh.id"/>" type="checkbox" />
			        </td>
					<td class="tb-td"><s:property value="#sh.accountNo"/></td>
					<td class="tb-td">
			        	<s:property value="#sh.cardType"/>
			        </td>
					<td class="tb-td"><s:property value="#sh.userName"/></td>
			        <td class="tb-td"><s:property value="#sh.cardNo"/></td>	
			        <td class="tb-td">
			        <s:if test="#sh.ext1 != null && #sh.ext1 != ''">
			        <s:property value="#sh.ext1"/>--<s:property value="#sh.ext2"/>
			        </s:if>
			        </td>			        
			        <td class="tb-td"><s:property value="#sh.createAtStr"/></td>
			      </tr>
			</s:iterator>	
        </tbody>
    </table>
   
</div>
 <s:if test="#request.msg !=null">
		<script language="javascript">
			alert("${request.msg}");
		</script>
	</s:if>
</body>
</html>